﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data.SqlClient;

namespace CMN.Entity
{
    public enum CommandNextType
    {
        /// <summary>
        /// 对其他语句无任何影响 
        /// </summary>
        None,
       
        /// <summary>
        /// 当前语句影响到的行数必须大于0，否则回滚事务
        /// </summary>
        ExcuteEffectRows
    }
    /// <summary>
    /// 执行语句信息
    /// </summary>
    public class CommandInfo
    {
        public object ShareObject = null;
        public object OriginalData = null;
        event EventHandler _solicitationEvent;
        public event EventHandler SolicitationEvent
        {
            add
            {
                _solicitationEvent += value;
            }
            remove
            {
                _solicitationEvent -= value;
            }
        }
        public void OnSolicitationEvent()
        {
            if (_solicitationEvent != null)
            {
                _solicitationEvent(this, new EventArgs());
            }
        }
        public string CommandText;
        public System.Data.Common.DbParameter[] Parameters;
        public System.Data.CommandType CommandType;
        /// <summary>
        /// 当前语句影响值的处理方式
        /// </summary>
        public CommandNextType CommandNextType = CommandNextType.None;
        public CommandInfo()
        {

        }
       
        public CommandInfo(string sqlText, System.Data.Common.DbParameter[] para, System.Data.CommandType commandType)
        {
            this.CommandText = sqlText;
            this.Parameters = para;
            this.CommandType = commandType;
        }
        public CommandInfo(string sqlText, System.Data.Common.DbParameter[] para, CommandNextType type, System.Data.CommandType commandType)
        {
            this.CommandText = sqlText;
            this.Parameters = para;
            this.CommandNextType = type;
            this.CommandType = commandType;
        }
    }
}